/*     */ package com.zimbra.cs.account;
/*     */ 
/*     */ import com.google.common.base.Joiner;
/*     */ import com.google.common.base.Objects;
/*     */ import com.google.common.base.Objects.ToStringHelper;
/*     */ import com.zimbra.common.account.Key.DomainBy;
/*     */ import com.zimbra.common.account.Key.ServerBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class XMPPComponent
/*     */   extends NamedEntry
/*     */   implements Comparable
/*     */ {
/*     */   public XMPPComponent(String name, String id, Map<String, Object> attrs, Provisioning prov)
/*     */   {
/*  34 */     super(name, id, attrs, null, prov);
/*     */   }
/*     */   
/*     */   public Entry.EntryType getEntryType()
/*     */   {
/*  39 */     return Entry.EntryType.XMPPCOMPONENT;
/*     */   }
/*     */   
/*     */   public String getComponentCategory() {
/*  43 */     return getAttr("zimbraXMPPComponentCategory");
/*     */   }
/*     */   
/*     */   public String getComponentType() {
/*  47 */     return getAttr("zimbraXMPPComponentType");
/*     */   }
/*     */   
/*     */   public String getLongName() {
/*  51 */     return getAttr("zimbraXMPPComponentName");
/*     */   }
/*     */   
/*     */   public String getClassName() {
/*  55 */     return getAttr("zimbraXMPPComponentClassName");
/*     */   }
/*     */   
/*     */   public String getShortName() throws ServiceException {
/*  59 */     String name = getName();
/*  60 */     Domain d = getDomain();
/*  61 */     if (d == null) {
/*  62 */       throw ServiceException.FAILURE("Invalid configuration data: XMPPComponent name, \"" + name + "\" points to nonexistent domain: " + getDomainId(), null);
/*     */     }
/*     */     
/*  65 */     String domainName = d.getName();
/*  66 */     if (!name.endsWith(domainName)) {
/*  67 */       throw ServiceException.FAILURE("Invalid configuration data: XMPPComponent name, \"" + name + "\" must be a subdomain of domain \"" + domainName + "\"", null);
/*     */     }
/*     */     
/*     */ 
/*  71 */     String toRet = name.substring(0, name.length() - domainName.length() - 1);
/*  72 */     return toRet;
/*     */   }
/*     */   
/*     */   public List<String> getComponentFeatures() {
/*  76 */     List<String> toRet = null;
/*  77 */     String[] features = getMultiAttr("zimbraXMPPComponentFeatures");
/*  78 */     if ((features != null) && (features.length > 0)) {
/*  79 */       toRet = new ArrayList(features.length);
/*  80 */       for (String s : features)
/*  81 */         toRet.add(s);
/*     */     } else {
/*  83 */       toRet = new ArrayList();
/*     */     }
/*  85 */     return toRet;
/*     */   }
/*     */   
/*     */   public String getDomainId() {
/*  89 */     return getAttr("zimbraDomainId");
/*     */   }
/*     */   
/*  92 */   public Domain getDomain() throws ServiceException { return Provisioning.getInstance().get(Key.DomainBy.id, getDomainId()); }
/*     */   
/*     */   public String getServerId()
/*     */   {
/*  96 */     return getAttr("zimbraServerId");
/*     */   }
/*     */   
/*  99 */   public Server getServer() throws ServiceException { return Provisioning.getInstance().get(Key.ServerBy.id, getServerId()); }
/*     */   
/*     */ 
/*     */   public String toString()
/*     */   {
/* 104 */     Objects.ToStringHelper helper = Objects.toStringHelper(this).add("name", getName()).add("category", getComponentCategory()).add("type", getComponentType());
/*     */     
/* 106 */     helper.add("domainId", getDomainId());
/* 107 */     Domain domain = null;
/*     */     try {
/* 109 */       domain = getDomain();
/*     */     }
/*     */     catch (ServiceException e) {}
/* 112 */     if (domain != null) {
/* 113 */       helper.add("domainName", domain.getName());
/*     */     }
/* 115 */     helper.add("serverId", getServerId());
/* 116 */     Server server = null;
/*     */     try {
/* 118 */       server = getServer();
/*     */     }
/*     */     catch (ServiceException e) {}
/* 121 */     if (server != null) {
/* 122 */       helper.add("serverName", server.getName());
/*     */     }
/* 124 */     helper.add("feature", Joiner.on(',').join(getComponentFeatures()));
/* 125 */     return helper.toString();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/XMPPComponent.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */